//
//  ColumnView.m
//  Tianmao
//
//  Created by dllo on 15/7/23.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ColumnView.h"
#import "CircleView.h"

#import "DKNightVersion.h"

#define RowNum 2
#define LineNum 4


@implementation ColumnView

-(instancetype)initWithFrame:(CGRect)frame
                   imageName:(NSArray *)imageNameArray
                        text:(NSArray *)textArray
{
    self = [super initWithFrame:frame];
    if (self) {
        [DKNightVersionManager addClassToSet:self.class];
        self.nightBackgroundColor = UIColorFromRGB(0x343434);

        [self createView:imageNameArray text:textArray];
    }
    return self;
}

- (void)createView:(NSArray *)imageNameArray text:(NSArray *)textArray{
    
    CGFloat width = [UIScreen mainScreen].bounds.size.width / 4;
    
    for (int i = 0; i < RowNum * LineNum; i++) {
        CircleView *view = [[CircleView alloc] initWithFrame:CGRectMake((
   i % LineNum ) * width, (i / LineNum ) * 90, width, 100) imageName:[imageNameArray objectAtIndex:i] title:[textArray objectAtIndex:i]];
        view.tag = i + 1;
        view.target = self;
        view.action = @selector(viewAction:);
        [self addSubview:view];
        [view release];
    }
}

- (void)viewAction:(CircleView *)view
{
    [self.delegate valueWithTag:view.tag];
}

@end
